package com.superm.controller;

import com.superm.entity.Emp;
import com.superm.entity.SaleOrder;
import com.superm.entity.SaleOrderDetails;
import com.superm.service.SaleODetService;
import com.superm.service.SaleOrderService;
import com.superm.utils.EmpContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/printouts")
public class PrintoutsController {
    @Autowired
    private SaleOrderService saleOrderService;
    @Autowired
    private SaleODetService saleODetService;
    @RequestMapping("/index")
    private ModelAndView index(){
        Emp emp = EmpContent.EmpUtils();
        ModelAndView ma = new ModelAndView("retail/printouts/Printouts");
        List<SaleOrder> saleOrders =saleOrderService.allSaleEmpid(emp.geteId());
        //订单对象
        SaleOrder saleOrder = new SaleOrder();
        for (SaleOrder s : saleOrders){
            saleOrder = s;
        }
        //订单详情集合
        List<SaleOrderDetails> details =saleODetService.allSaleOid(saleOrder.getSaleOrderId());
        //前台操作人
        ma.addObject("saleOrder",saleOrder);
        ma.addObject("details",details);
        ma.addObject("emp",emp.geteName());
        return ma;
    }
}
